^A^D^ORANDOM (?) NUMBERS^F^J^E^P^R 
^DCONTINUED FROM LAST ISSUE. Methods of generating random numbers in 
SmartBasic.^E ^Q 
Similar to one of last month but this one uses a controller keypad response 
rather than a keyboard response. 
10 PRINT "PRESS # ON KEYPAD TO BEGIN" ^I This message is printed on screen. 
^F^J 
20 a% = a% -1: IF not PDL(11) THEN GOTO 20 ^F^J the value a% will decrease by 
l each time this line is run. If the # on keypad is touched then PDL(ll) will 
register and the program goes to line 30.  However, if # on the keypad has 
not been push, PDL(11) does not register and the line 20 is run again, which 
causes the value of a% to decrease again.  Based on the time it takes to push 
the # on the keypad the value a% will have decreased by varying amounts.^F^J 
30 rn = RND(a%) ^IThis sets the random number equal to a random number based 
on a%.  As a% will vary (see line 20 above), the random number series will 
vary with it. ^F^J 
40 REM Continue with your program ^IAgain REM is merely a remark and the 
program does not try to run it.^F^J. 
A similar program creates an input polling loop (asks if a certain input has 
been made) which such loop can be exited when the user presses a certain key. 
The loop updates the potential seed number on each loop, as a result the 
randomness of the seed is based on pressing a key at a random time. 
100 For seed = 1 to 5000 ^IBeginning of loop^F^J 
110 IF PDL(9) = l THEN l30 ^IWhen proper key is pressed, PDL(9) then the 
program goes to line l30 where it determines a random number for the balance 
of the progran.^F^J 
120 NEXT seed ^Icompletes the FOR-THEN loop and loops back to 100^F^J 
130 seed = RND (-seed) ^I Use the random seed from the loop to get a random 
number for your program. ^F^J 
Another technique uses the computer's clock. This involveds a short machine 
code routine. The routine takes a number of the refresher register of the 
Z80CPU and stores it a location l056. The refresher register is incremented 
by the computer clock. The routine should be loaded at the beginning of the 
program, as indicated. 
100 FOR i = 0 to 5: READ d: POKE l056+i,d: NEXT i 
110 DATA 237,95,50,38,4,20l 
The routine is loaded in a safe place in the Basic Interpreter so no LOMEM or 
HIMEM statemebts are necessary.  You use the routine as follows: 
200 CALL l056: x = RND (-PEEK(l062)) 
Sounds nice, if anyone has tried this, let me know.  I have just found this 
one in an old Adam journal but not exactly sure how it works. But since no 
one every responses, I am sure no one will let me know more about this.
 
^DAT THIS POINT I RECEIVED MY COPY OF GODOS WITH GOBASIC^E and decided to 
finish this article by indicating what you must go through to get a true 
random number with GODOS.
 
^DGODOS RANDOM NUMBERS^E 
To generate a TRUE random number in GODOS, forget about all the above which 
has to do with SmartBasic and:

 
Type in RND wherever you want a random number, such as ..........
 
l0 IF RND (l) > 0.56 THEN .........
 
Thats all you need, just type in RND wherever you want a TRUE RND and thats 
what you get.  No fancy manipulations as with SmartBasic. 
^B^E^F^J
 

